<include file="public@header" />
<style>
    .expander{margin-left: -20px;}
    label{font-weight: normal;}
</style>
</head>
<body>
    <div class="layui-fluid js-check-wrap">
        
        <form class="js-ajax-form"  action="{:url('AdminGoodsCategory/showPost')}" method="post">
            <div class="table_full">
                <table class="table table-bordered" id="authrule-tree">
                    <tbody>
                        <!-- <tr><td style="color:#18BC9C;" >勾选要发布的栏目</td></tr> -->
                        {$category}
                    </tbody>
                </table>
            </div>
            <div class="form-actions">
                <input type="hidden" name="roleId" value="{$roleId}" />
                <button class="layui-btn layui-btn-normal js-ajax-submit" type="submit">{:lang('SAVE')}</button>
            </div>
        </form>
    </div>
    <script src="__STATIC__/js/admin.js"></script>
    <script type="text/javascript">
    $(document).ready(function () {
        Wind.css('treeTable');
        Wind.use('treeTable', function () {
            $("#authrule-tree").treeTable({
                indent: 20,
                // initialState:'expanded',//默认是否展开和关闭： values: "expanded" or "collapsed"
            });
        });
    });

    function checknode(obj) {
        var chk = $("input[type='checkbox']");
        var count = chk.length;

        var num = chk.index(obj);
        var level_top = level_bottom = chk.eq(num).attr('level');
        for (var i = num; i >= 0; i--) {
            var le = chk.eq(i).attr('level');
            if (le <level_top) {
                chk.eq(i).prop("checked", true);
                var level_top = level_top - 1;
            }
        }
        for (var j = num + 1; j < count; j++) {
            var le = chk.eq(j).attr('level');
            if (chk.eq(num).prop("checked")) {

                if (le > level_bottom){
                    chk.eq(j).prop("checked", true);
                }
                else if (le == level_bottom){
                    break;
                }
            } else {
                if (le >level_bottom){
                    chk.eq(j).prop("checked", false);
                }else if(le == level_bottom){
                    break;
                }
            }
        }
    }
    </script>
</body>
</html>
